use actix_web::{get, web, App, HttpServer, Responder};
use serde::{Deserialize, Serialize};

#[get("/")]
async fn index() -> impl Responder {
    "Hello, World!"
}


#[derive(Serialize, Deserialize)]
struct User {
    id: i32,
    name: String,
}

#[get("/users")]
async fn get_users() -> impl Responder {
    let users = vec![
        User { id: 1, name: "Alice".to_string() },
        User { id: 2, name: "Bob".to_string() },
    ];
    web::Json(users)
}


#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new().service(index).service(get_users))
        .bind(("0.0.0.0", 8888))?
        .run()
        .await
}